﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace HowHigh
{
    public partial class AllProjects : PhoneApplicationPage
    {
        public AllProjects()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(AllProjects_Loaded);
        }

        void AllProjects_Loaded(object sender, RoutedEventArgs e)
        {
            listBox1.ItemsSource = Model.DBDataContext.Default.TowPointProjet.OrderByDescending(i=>i.LastUpdate).ToList();
            listBox1.SelectedIndex = -1;
        }

        private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var p = listBox1.SelectedItem as Model.Project;
            App.Current.CurrentProject = p;
            if(p!=null)
                NavigationService.Navigate(new Uri("/TestPage.xaml",UriKind.Relative));
        }
    }
}